﻿// =================================================================== 
// 项目说明
//====================================================================
// liucx。@Copy Right 2019
// 文件： VehicleLicense.cs
// 项目名称：斑马车务
// 创建时间：2019/9/17
// 负责人：liucx
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using Dapper.Extensions;
using YouWei.Infrastructure.Entity;
using YouWei.Infrastructure.Repository;
using YouWei.Infrastructure.Models;

namespace YouWei.Infrastructure.Service
{

    /// <summary>
    ///
    /// </summary>
    public class VehicleLicenseService
    {
        protected VehicleLicenseRepository repository;

        public VehicleLicenseService()
        {
            repository = new VehicleLicenseRepository();
        }

        #region 增删改查

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(VehicleLicense entity) { return repository.Insert(entity); }

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(List<VehicleLicense> entitys) { return repository.Insert(entitys); }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Update(VehicleLicense entity) { return repository.Update(entity); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Delete(VehicleLicense entity) { return repository.Delete(entity); }

        /// <summary>
        /// 删除所有
        /// </summary>
        /// <returns></returns>
        public bool DeleteAll() { return repository.DeleteAll(); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public bool Delete(int primaryKey) { return repository.Delete(primaryKey); }

        /// <summary>
        /// 查询单个实体
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public VehicleLicense SingleOrDefault(object primaryKey) { return repository.SingleOrDefault(primaryKey); }


        /// <summary>
        /// 查询单个实体,如果存在多条则引发异常
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public VehicleLicense Single(object primaryKey) { return repository.Single(primaryKey); }

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns></returns>
        public List<VehicleLicense> QueryAll()
        {
            return repository.QueryAll();
        }

        #endregion

        /// <summary>
        /// 根据用户ID获取行驶证详情
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public List<VehicleLicense> GetByUser(int UserID)
        {
            return repository.GetByUser(UserID);
        }

        /// <summary>
        /// 根据用户ID获取行驶证详情
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public VehicleLicense GetByUserPlateNum(int UserID, string PlateNo)
        {
            return repository.GetByUserPlateNum(UserID, PlateNo);
        }

        /// <summary>
        /// 根据车型ID获取用户行驶证信息
        /// </summary>
        /// <param name="modelId"></param>
        /// <returns></returns>
        public List<VehicleUser> GetListByModelId(int modelId)
        {
            return repository.GetListByModelId(modelId);
        }

        /// <summary>
        /// 分页查询行驶证列表
        /// 此方法仅用于管理员
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public Page<VehicleLicenseMode> Pages(int pageIndex, int pageSize, VehicleLicenseSearchModel model)
        {
            return repository.Pages(pageIndex, pageSize, model);
        }

        /// <summary>
        /// 获取审核列表
        /// </summary>
        /// <returns></returns>
        public List<VehicleLicense> GetInspectList()
        {
            return repository.GetInspectList();
        }
    }

}